<?php

    class itZendStyleTemplateTest extends itTestCase {
        
        public function testConstructor() {
            $template = new itZendStyleTemplate('AAA', 'BBB');
            $this->assertEquals('AAA', $template->getPrefix());
            $this->assertEquals('BBB', $template->getPostfix());
            
            $template = new itZendStyleTemplate();
            $this->assertEquals('.php', $template->getPostfix());
        }
        
        /**
         * @test
         */
        public function testGeneral() {
            $template = new itZendStyleTemplate();
            $template->setPrefix('A');
            $this->assertEquals('A', $template->getPrefix());
            $template->setPostfix('B');
            $this->assertEquals('B', $template->getPostfix());
            $template->setNamespaceAsDir(false);
            $this->assertFalse($template->isNamespaceAsDir());
            $template->acceptUnregisteredNamespaces(false);
            $this->assertFalse($template->isAcceptUnregisteredNamespaces());
            $this->assertEquals(array(null), $template->getRegisteredNamespaces()); // default
        }
        
        /**
         * @test
         */
        public function testNamespaceAsDir() {
            $template = new itZendStyleTemplate();
            $template->setPrefix('/home/drapeko/');
            $template->setNamespaceAsDir();
            $result = $template->getPath('Sedulinos\12R1');
            $this->assertEquals(1, count($result));
            $this->assertTrue(stripos($result[0], 'Sedulinos') !== false);
            $template->setNamespaceAsDir(false);
            $result = $template->getPath('Sedulinos\12R1');
            $this->assertEquals(1, count($result));
            $this->assertTrue(stripos($result[0], 'Sedulinos') === false);
        }
        
        /**
         * @test
         */
        public function testAcceptUnregisteredNamespaces() {
            $template = new itZendStyleTemplate();
            $template
                ->setPrefix('/home/drapeko/')
                ->acceptUnregisteredNamespaces(false);
            $this->assertEquals(1, count($template->getPath('A'))); // default accepted namespace is null
            $this->assertEquals(0, count($template->getPath('A\A')));
            $template->setRegisteredNamespaces(array(null, 'A'));
            $this->assertEquals(1, count($template->getPath('A\A')));
        }
    }
    
?>